let defaultValue = {} // 子应用的沙箱容器
class ProxySandbox {
  constructor() {
    this.proxy = null
    this.active()
  }
  // 沙箱激活
  active() {
    // 子应用需要设置属性，拦截到到后 设置到其他容器上
    this.proxy = new Proxy(window, {
      get(target, key) {
        console.log('get', target, key)
        return defaultValue[key]
      },
      set(target, key, value) {
        console.log('set', key, value)
        defaultValue[key] = value
        return true
      }
    })
  }
  // 沙箱销毁
  inactive() {
    defaultValue = {}
  }
}

let proxy = new ProxySandbox()

const str = `
  return ((window) => {
    return 1
  })(window)
`

const res = new Function(str)
